/*
 * @Author: humengchuan 531537052@qq.com
 * @Date: 2024-10-22 11:26:07
 * @LastEditors: humengchuan 531537052@qq.com
 * @LastEditTime: 2024-10-22 11:27:30
 * @FilePath: \projecte:\学习\react\react-optimize-ts\src\utils\request.ts
 * @Description: 
 */
import axios from "axios";


export const request = axios.create({
  baseURL: import.meta.env.VITE_BASE_URL,
  timeout: 10000,
});

request.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

request.interceptors.response.use(
  (response) => {
    return Promise.resolve(response.data);
  },
  (error) => {
    return Promise.reject(error);
  }
);

export const get = (url: string, params?: any) => {
  return request.get(url, { params });
};

export const post = (url: string, params?: any) => {
  return request.post(url, params);
};

export const put = (url: string, params?: any) => {
  return request.put(url, params);
};

export const del = (url:string, params?: any) => {
    return request.delete(url, params);
}

export const patch = (url: string, params?: any) => {
  return request.patch(url, params);
};

